import {RequestHandler} from 'express-serve-static-core';
import {matchRoutes} from 'react-router-dom';
import routes from '../../src/routes';

const analyzeRouteStatus: RequestHandler = async (req, res, next) => {
	const {isPc, needPassword, deployPath, routePath} = req.meoData;
	// const routes = getRoutes({isPc, needPassword}, deployPath);
	const matchedRoute = matchRoutes(routes, routePath)[0];
	Object.assign(req.meoData, {matchedRoute});
	next();
};

export default analyzeRouteStatus;
